﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace ConfigInfo
{

    public partial class ConfigInfo : Form
    {
       public  string selectpathconfig = "";
       
      
        public ConfigInfo(string path)           
        {          
            InitializeComponent();
            selectpathconfig = path;
            string filenameSiteInfo = selectpathconfig + "\\" + "SiteInfo.dat ";
            if (File.Exists(filenameSiteInfo))
            {
                StreamReader sr = new StreamReader(filenameSiteInfo, System.Text.Encoding.Default);
                String line;
                try
                {
                    sr.ReadLine();
                    line = sr.ReadLine();//out.t76
                    if (line == null || line == "")
                    {
                        MessageBox.Show("配置文件错误"); return;
                    }
                    string stationName = line + ".info";
                    filenameSiteInfo = selectpathconfig + "\\" + stationName;
                    ReadData(filenameSiteInfo);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("配置文件错误");
                }
            }
            else
            {
                MessageBox.Show("当前文件夹不存在SiteInfo.dat文件");
            }
        }


    
        
       
        

        public void ReadData(string path)
        {
           StreamReader sr = new StreamReader(path, System.Text.Encoding.Default);
            String line;
            try
            {
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox0.Text = line;

                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox1.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox2.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox3.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox4.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox5.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox6.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox7.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox8.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox9.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox10.Text = line;
                sr.ReadLine();
                line = sr.ReadLine();//out.t76
                this.textBox11.Text = line;
            }
            catch (Exception ex)
            {
                MessageBox.Show("配置文件错误");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
